//
//  GHStudyTableViewCell.m
//  GodHorses
//
//  Created by Mac on 2017/11/18.
//  Copyright © 2017年 stoneobs@icloud.com. All rights reserved.
//

#import "GHStudyTableViewCell.h"
@interface GHStudyTableViewCell ()
@property(nonatomic, strong) UIImageView                     *iconImageView;
@property(nonatomic, strong) STLabel                         *titleLable;
@property(nonatomic, strong) STButton                        *readButton;
@property(nonatomic, strong) STLabel                         *commentNumLable;
@end
@implementation GHStudyTableViewCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self == [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self configSubView];
    }
    return self;
}
+ (CGFloat)cellHeight{
    return 140;
}
#pragma mark --subView
- (void)configSubView{
    self.backgroundColor = [UIColor whiteColor];
    self.iconImageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 5, 160, [GHStudyTableViewCell cellHeight] - 10)];
    [self addSubview:self.iconImageView];
    
    STLabel * titleLable = [[STLabel alloc] initWithFrame:CGRectMake(self.iconImageView.st_right + 10, 15, UIScreenWidth - self.iconImageView.right - 20, 40)
                                                     text:@"神马合作项目"
                                                textColor:GH_firstTextColor
                                                     font:14
                                              isSizetoFit:NO
                                            textAlignment:NSTextAlignmentLeft];
    self.titleLable = titleLable;
    self.titleLable.numberOfLines = 0;
    [self addSubview:self.titleLable];
    
    self.commentNumLable = [[STLabel alloc] initWithFrame:CGRectMake(0, 0, 80, 15)
                                                     text:@"15评论"
                                                textColor:GH_firstTextColor
                                                     font:14
                                              isSizetoFit:NO
                                            textAlignment:NSTextAlignmentRight];
    self.commentNumLable.st_right = UIScreenWidth - 10;
    self.commentNumLable.st_bottom = [GHStudyTableViewCell cellHeight] - 10;
    [self addSubview:self.commentNumLable];
    
    self.readButton = [[STButton alloc] initWithFrame:CGRectMake(0, 0, 100, 20)
                                                     title:@"23阅读"
                                                titleColor:GH_firstTextColor
                                                 titleFont:14
                                              cornerRadius:0
                                           backgroundColor:nil
                                           backgroundImage:nil
                                                     image:[UIImage imageNamed:@"wde"]];
    self.readButton.st_right = self.commentNumLable.left - 3;
    self.readButton.centerY = self.commentNumLable.centerY;
    [self.readButton setTitleEdgeInsets:UIEdgeInsetsMake(0, 5, 0, 0)];
    [self addSubview:self.readButton];
}
- (void)setModel:(GHStudyModel *)model{
    _model = model;
    
    [self.iconImageView sd_setImageWithURL:[NSURL URLWithString:model.a_img] placeholderImage:GH_placeHoderImage];
    
    self.titleLable.text = model.title;
    
    self.commentNumLable.text = [NSString stringWithFormat:@"%@评论",model.comment];
    
    [self.readButton setTitle:[NSString stringWithFormat:@"%@阅读",model.click] forState:UIControlStateNormal];
    
}
@end
